#include <stdio.h>
#include <io.h>
#include <string>
#include <ifstream>
using namespace std;

void handleFile(string& fileName)
{
    ifstream readfile;

}

int main (void)
{
    _finddata_t fileDir;
    //const char* dir = "d:\\temp\\*.*";
    const char* dir = "logs\\*.*";
    long lfDir;
    //存放临时文件名
    string tempName;
    //_findfirst返回的是long型; long __cdecl _findfirst(const char *, struct _finddata_t *)
    if((lfDir = _findfirst(dir,&fileDir)) == -1l)
        printf("No file is found\n");
    else
    {
        printf("file list:\n");
        do
        {
            tempName = fileDir.name;
            //如果以.开头 跳过
            if(tempName[0] == '.') continue;
            printf("%s\n",fileDir.name);
            //处理文件逻辑
            handleFile(string myFileName);

        }while( _findnext( lfDir, &fileDir ) == 0 );//如果找到下个文件的名字成功的话就返回0,否则返回-1
    }
    _findclose(lfDir);

    return 0;
}
